package ch.pizzapp.kurier.adapter;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import ch.pizzapp.kurier.data.NotificationData;
import ch.pizzapp.kurier.view.NotificationItem;
import ch.pizzapp.kurier.view.NotificationItem_;

@EBean
public class NotificationAdapter extends BaseAdapter {

	List<NotificationData> notificationDataData;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		NotificationItem notificationItem;
		if (convertView == null) {
			notificationItem = NotificationItem_.build(context);
		} else {
			notificationItem = (NotificationItem) convertView;
		}

		notificationItem.bind(getItem(position));

		return notificationItem;
	}

	public List<NotificationData> getNotificationDataData() {
		return notificationDataData;
	}

	public void setNotificationDataData(
			List<NotificationData> notificationDataData) {
		this.notificationDataData = notificationDataData;
	}

	@Override
	public int getCount() {
		return notificationDataData.size();
	}

	@Override
	public NotificationData getItem(final int position) {
		return notificationDataData.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
